package com.utils;
import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtils extends org.apache.commons.lang3.StringUtils{
	private static Pattern patternMobile = Pattern.compile("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17([0,1,6,7,]))|(18[0-2,5-9]))\\d{8}$");
	  private static Pattern patternEmail = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.([a-zA-Z0-9_-])+)+$");

	  public static boolean isEmail(CharSequence email)
	  {
	    Matcher m = patternEmail.matcher(email);
	    return m.matches();
	  }

	  public static boolean isMobile(CharSequence mobiles)
	  {
	    Matcher m = patternMobile.matcher(mobiles);
	    return m.matches();
	  }

	  public static String fromCamelCase(String input, char separator)
	  {
	    int length = input.length();
	    StringBuilder result = new StringBuilder(length * 2);
	    int resultLength = 0;
	    boolean prevTranslated = false;
	    for (int i = 0; i < length; i++) {
	      char c = input.charAt(i);
	      if ((i > 0) || (c != separator)) {
	        if (Character.isUpperCase(c)) {
	          if ((!prevTranslated) && (resultLength > 0) && (result.charAt(resultLength - 1) != separator)) {
	            result.append(separator);
	            resultLength++;
	          }
	          c = Character.toLowerCase(c);
	          prevTranslated = true;
	        } else {
	          prevTranslated = false;
	        }
	        result.append(c);
	        resultLength++;
	      }
	    }
	    return resultLength > 0 ? result.toString() : input;
	  }

	  public static String toCamelCase(String input, boolean firstCharUppercase, char separator)
	  {
	    int length = input.length();
	    input = input.toLowerCase();
	    StringBuilder sb = new StringBuilder(length);
	    boolean upperCase = firstCharUppercase;

	    for (int i = 0; i < length; i++) {
	      char ch = input.charAt(i);
	      if (ch == separator) {
	        upperCase = true;
	      } else if (upperCase) {
	        sb.append(Character.toUpperCase(ch));
	        upperCase = false;
	      } else {
	        sb.append(ch);
	      }
	    }
	    return sb.toString();
	  }

	  public static String toCamelCase(String input)
	  {
	    return toCamelCase(input, false, '_');
	  }

	  public static String toSafeString(Object value)
	  {
	    return value == null ? "" : value.toString();
	  }

	  public static String toLowerCase(String s)
	  {
	    if (s == null) {
	      return null;
	    }
	    StringBuilder sb = null;
	    int len = s.length();
	    for (int i = 0; i < len; i++) {
	      char c = s.charAt(i);
	      if (c > '') {
	        return s.toLowerCase();
	      }
	      if ((c >= 'A') && (c <= 'Z')) {
	        if (sb == null) {
	          sb = new StringBuilder(s);
	        }
	        sb.setCharAt(i, (char)(c + ' '));
	      }
	    }
	    if (sb == null) {
	      return s;
	    }
	    return sb.toString();
	  }

	  public static String toUpperCase(String s)
	  {
	    if (s == null) {
	      return null;
	    }
	    StringBuilder sb = null;
	    for (int i = 0; i < s.length(); i++) {
	      char c = s.charAt(i);
	      if (c > '') {
	        return s.toUpperCase();
	      }
	      if ((c >= 'a') && (c <= 'z')) {
	        if (sb == null) {
	          sb = new StringBuilder(s);
	        }

	        sb.setCharAt(i, (char)(c - ' '));
	      }
	    }
	    if (sb == null) {
	      return s;
	    }
	    return sb.toString();
	  }

	  public static boolean startsWithChar(String s, char c)
	  {
	    return (s.length() != 0) && (s.charAt(0) == c);
	  }

	  public static boolean endsWithChar(String s, char c)
	  {
	    return (s.length() != 0) && (s.charAt(s.length() - 1) == c);
	  }

	  public static String surround(String str, char c, boolean prefix, boolean suffix)
	  {
	    int len = str.length();
	    int newlen = len;
	    if (prefix) {
	      newlen++;
	    }
	    if (suffix) {
	      newlen++;
	    }
	    char[] buf = new char[newlen];
	    int pos = 0;
	    if (prefix) {
	      buf[(pos++)] = c;
	    }
	    str.getChars(0, len, buf, pos);
	    if (suffix) {
	      buf[(len + pos)] = c;
	    }
	    return new String(buf);
	  }

	  public static String surround(String str, String fix, boolean prefix, boolean suffix)
	  {
	    int len = str.length();
	    int newlen = len;
	    int fixlen = fix.length();
	    if (prefix) {
	      newlen += fixlen;
	    }
	    if (suffix) {
	      newlen += fixlen;
	    }
	    char[] buf = new char[newlen];
	    int pos = 0;
	    if (prefix) {
	      fix.getChars(0, fixlen, buf, 0);
	      pos += fixlen;
	    }
	    str.getChars(0, len, buf, pos);
	    if (suffix) {
	      fix.getChars(0, fixlen, buf, pos + len);
	    }
	    return new String(buf);
	  }

	  public static String surroundIfMissing(String str, char c)
	  {
	    boolean prefix = false; boolean suffix = false;
	    if (!startsWithChar(str, c)) {
	      prefix = true;
	    }
	    if (!endsWithChar(str, c)) {
	      suffix = true;
	    }
	    return surround(str, c, prefix, suffix);
	  }

	  public static String surroundIfMissing(String str, String fix)
	  {
	    boolean prefix = false; boolean suffix = false;
	    if (!str.startsWith(fix)) {
	      prefix = true;
	    }
	    if (!str.endsWith(fix)) {
	      suffix = true;
	    }

	    return surround(str, fix, prefix, suffix);
	  }

	  public static boolean isLetter(char c) {
	    int k = 128;
	    return c / k == 0;
	  }

	  public static int lengthb(String cs) {
	    if (cs == null) {
	      return 0;
	    }
	    char[] c = cs.toCharArray();
	    int len = 0;
	    for (char aC : c) {
	      len++;
	      if (!isLetter(aC)) {
	        len++;
	      }
	    }
	    return len;
	  }

	  public static void main(String[] args)
	  {
	    System.out.println(join(new Serializable[] { null, "", Integer.valueOf(223) }));
	  }
}
